/* 
* @Author: Vison
* @Date:   2017-04-01 13:00
* @Last Modified by:   Vison
* @Last Modified time: 2017-04-03 15:00:00
*/

$(function(){

	indedNav();
	Sidebar();
	footerCont();
	headerAct();
	
});
function indedNav(){
    var nav_html= 	"<header data-am-widget='header' class='am-header am-header-default hm-head-bg'>"+
						"<div class='am-container'>"+
							"<div class='am-header-nav'>"+
								"<a href='index.html' class=''>"+
									"<img class='am-header-icon-custom hm-header-logo' src='assets/images/logo.png' alt=''/>"+
								"</a>"+
							"</div>"+
							"<div class='am-collapse am-topbar-collapse' id='collapse-head'>"+
								"<ul class='am-nav am-nav-pills am-topbar-right hm-nav-pill' id='hm-nav-list'>"+
									"<li><a href='index.html'>首页</a></li>"+
									"<li><a href='product.html'>产品中心</a></li>"+
									"<li><a href='activity.html'>活动专栏</a></li>"+
									"<li><a href='joinus.html'>加入我们</a></li>"+
									"<li><a href='about.html'>关于我们</a></li>"+
								"</ul>"+
							"</div>"+
						"</div>"+
					"</header>";

        $("#hm-wapper").prepend(nav_html);

}


function Sidebar(){
     var side_html=	"<div class='am-g am-g-fixed hm-show-sm-only'>"+
						"<div class='am-u-md-3 am-u-md-pull-9 my-sidebar'>"+
							"<div class='am-offcanvas' id='sidebar'>"+
								"<div class='am-offcanvas-bar'>"+
									"<div class='hm-align-transform'>"+
										"<div class='hm-logo-ds'>"+
											"<img alt='Logo' class='hm-ds-logosize' src='assets/images/hm_logo02.png'>"+
										"</div>"+
										"<ul class='am-nav'>"+
											"<li><a href='index.html'>首页</a></li>"+
											"<li><a href='product.html'>产品中心</a></li>"+
											"<li><a href='activity.html'>活动专栏</a></li>"+
											"<li><a href='joinus.html'>加入我们</a></li>"+
											"<li><a href='about.html'>关于我们</a></li>"+
										"</ul>"+
										"<div class='hm-ds-text'>"+
											"<p>"+
												"<small>Copyright© 2017嗨萌</small>"+
											"</p>"+
										"</div>"+
									"</div>"+				
									"<div class='hm-close-nav'>"+
										"<a href='#' class='hm-close'></a>"+
									"</div>"+
								"</div>"+
							"</div>"+
						"</div>"+
						"<a href='#sidebar' class='am-btn am-btn-sm am-btn-success am-icon-bars am-show-sm-only my-button' data-am-offcanvas><span class='am-sr-only'>侧栏导航</span></a>"+
					"</div>";

    $("#hm-wapper").append(side_html);
}



function footerCont(){
     var foot_html=	"<footer class='my-footer' id='hm-footer'>"+
						"<div class='hm-footer-cont'>"+
							"<span>Copyright©2017嗨萌</span>"+
							"<span>佛山市老板六六科技有限公司</span>"+
						"</div>"+
						"<div class='hm-footer-record'>备案许可证号：京ICP备14065197号-3</div>"+
						"<div class='hm-footer-tel'>联系电话：020-84073402</div>"+
					"</footer>";

    $("#hm-wapper").append(foot_html);
}


function headerAct(){
	activeOn("hm-nav-list");
}
function activeOn ($id) {
      var id = document.getElementById($id);
      var links=id.getElementsByTagName('a');
      index=0;
      url=location.href.split('?')[0].split('/').pop();
      if(url){
        for(var i=links.length;i--;){
          (function() {
            if(links[i].href.indexOf(url)!=-1){
              index=i;
            }
          })(i);
        }
      }
      links[index].className ='am-active';
}